<template>
  <div class="fillcontain">
    <head-top></head-top>
    <div class="table_container">

      <!--<el-button-->
        <!--type="primary"-->
        <!--@click="handleTAdd">上传模版</el-button>-->
      <!--列表-->
      <el-table :data="record" highlight-current-row v-loading="loading" style="width: 100%;">
        <el-table-column type="index" width="60"></el-table-column>
        <el-table-column prop="date" label="时间" sortable></el-table-column>
        <el-table-column prop="myUser" label="用户" sortable></el-table-column>
        <el-table-column prop="ip" label="ip" sortable></el-table-column>
        <!--<el-table-column prop="age" label="name数量" width="100" sortable>-->
        <!--</el-table-column>-->
      </el-table>
      <el-col :span="24" class="toolbar">
        <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="10" :total="total" style="float:right;">
        </el-pagination>
      </el-col>
    </div>
  </div>
</template>

<script>
  import headTop from './head.vue'
  import { loginRecord } from '@/api/api'
  export default {
    data () {
      return {
        loading: false,
        record: [],
        page: 1,
        total: 0
      }
    },
    components: {
      headTop
    },
    created () {
      this.initData()
    },
    methods: {
      // 获取设备名称
      async initData () {
        this.loading = true
        try {
          loginRecord(this.page).then((res) => {
            this.total = res.data.count
            this.record = res.data.results
            this.loading = false
          })
        } catch (err) {
          console.log('获取数据失败', err)
        }
      },
      handleCurrentChange (val) {
        this.page = val
        this.initData()
      }
    }
  }

</script>

<style scoped>
</style>
